
#include "type.h"
#include "sys.h"
#include "led.h"
#include "flash.h"
#include "vkos.h"
#include "wtdog.h"
#include "vklcslave.h"
#include "dev.h"
#include "flash.h"
#include "w25q64.h"

// *****************************************************************************
// 功能: 主函数
// 输入: 无
// 输出: 无
// *****************************************************************************
void main(void)
{    
    uint8 BootBuff[12]; uint32 Applen; uint32 Appmod;
    while(true)
        {
        WatchDog.Reload();
        W25q64.ReadBootMess(BootBuff,12);
        if(Sys.Comp(BootBuff,(string)"APP ",4) == false){break;}
        Applen = *(uint32*)(&BootBuff[4]);
        Appmod = *(uint32*)(&BootBuff[8]);
        if(Flashi.GetAppMod32(Applen) != Appmod){break;}
        Flashi.JumpToInapp();
        }
    Vkos.ThreadCreate("Commun",DevCommunSort,120,0);
    Vkos.ThreadCreate("Movement",DevMovementSort,120,0);
    Vkos.Start();
}